<%--
  Created by IntelliJ IDEA.
  User: zhouz
  Date: 2023/12/4
  Time: 15:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%--输入名字，当失去焦点时判断：name值为zhangsan则认为则显示”此用户已占用”，输入其他名字则显示“此用户可以使用”--%>
请输入名称：<input type="text" name="name" id="name"><span id="info"></span>


<script type="text/javascript" src="${pageContext.request.contextPath}/js/axios.js"></script>

<script type="text/javascript">
    let nameInput = document.getElementById("name");
    nameInput.onblur = function () {
        // 第一个参数：url
        // 第二个参数：携带的参数
        let url = "${pageContext.request.contextPath}/axios/check";
        axios.post(url, {"name": nameInput.value}).then(function (resp) {
            // console.log(resp);
            document.getElementById("info").innerHTML = resp.data.message;
        });
    }
</script>

</body>
</html>
